/*
 * This file is Copyright 2002-2006 Loyola University Chicago,
 * Department of Computer Science and the Emerging Technologies Laboratory.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License via
 *    http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.citep.db.hibernate;

import com.citep.business.Account;
import com.citep.business.AccountCategory;
import com.citep.business.AccountTypes;

import java.util.Set;
import java.util.Date;
import java.math.BigDecimal;

/**
 * Hibernate-specific implementation of edu.luc.cs.citep.business.Account.
 * 
 * <br><br>The generic getter and setter methods are designed to be used by Hibernate only and
 * are therefore designated as protected.  While some of the public methods required by
 * the interface simply duplicate the functionality of these protected methods, others 
 * do not, instead calling the manager to find and initialize collections from the
 * database.  The Hibernate methods and the public methods have been separated, though
 * to avoid confusion and allow for extensibility.  While this leads to a greater number 
 * of methods, it allows us to do any sort of meta-data tasks like logging or 
 * post-processing on attributes before we return them to the UI or push them back to
 * the DB.
 * 
 * @author mbone, bgonzalez
 * @since 8/10/2005
 */


public class AccountDAO extends Account {

	private AccountDAO parent;
	private Set<Account>children;// = new ArrayList();
	
	private int id;
	private String name;
	private String description;
	private BigDecimal currentBalance;
	private Date startPeriod;
	private Date endPeriod;
	private Date lastModified;
	
	private AccountTypes type;
	
	private boolean enabled;

	private AccountCategory accountCategory;
	
	
	/**
	 * @return Returns the accountCategory.
	 */
	public AccountCategory getAccountCategory() {
		return accountCategory;
	}
	/**
	 * @param accountCategory The accountCategory to set.
	 */
	public void setAccountCategory(AccountCategory accountCategory) {
		this.accountCategory = accountCategory;
	}
	/**
	 * @return Returns the id.
	 */
	public int getId() {
		return id;
	}
	/**
	 * @param id The id to set.
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	/**
	 * @return Returns the description.
	 */
	public String getDescription() {
		return description;
	}
	/**
	 * @param description The description to set.
	 */
	public void setDescription(String description) {
		this.description = description;
	}
	/**
	 * @return Returns the enabled.
	 */
	public boolean isEnabled() {
		return enabled;
	}
	/**
	 * @param enabled The enabled to set.
	 */
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	/**
	 * @return Returns the name.
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name The name to set.
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	public String toString() {
		return "[Account]: id=" + id + " | name: " + name + " | description: " + description + " | enabled: " + enabled + " | balance: " + getCurrentBalance();
	}
	public Date getEndPeriod() {
		return endPeriod;
	}
	public void setEndPeriod(Date endPeriod) {
		this.endPeriod = endPeriod;
	}
	public Date getStartPeriod() {
		return startPeriod;
	}
	public void setStartPeriod(Date startPeriod) {
		this.startPeriod = startPeriod;
	}

	public BigDecimal getCurrentBalance() {
		return currentBalance;
	}
	public void setCurrentBalance(BigDecimal currentBalance) {
		this.currentBalance = currentBalance;
	}
	
	
	public AccountTypes getType() {
		
		return type;
	}
	public void setType(AccountTypes type) {
		this.type = type;
	}
	public Set<Account> getChildren() {
		return (Set<Account>)children;
	}
	public Account getParent() {
		return parent;
	}
	public boolean hasChildren() {
		return (children != null && !children.isEmpty());
	}
	public boolean hasParent() {
		return parent != null;
	}
	public void setChildren(Set<Account> children) {
		this.children = children;
	}
	public void setParent(Account parent) {
		this.parent = (AccountDAO)parent;
	}
	public Date getLastModified() {
		return lastModified;
	}
	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}
	
}
